package com.education.service.edu.controller.web;

import com.education.result.R;
import com.education.service.edu.entity.Teacher;
import com.education.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 用户访问前端控制器
 * Created by Lance on 2020/07/01 18:03
 */
@Api(tags = "讲师管理")
@Slf4j
@RestController
@RequestMapping("/web/edu/teacher")
public class WebTeacherController {
    @Autowired
    private TeacherService teacherService;

    @ApiOperation(value="所有讲师列表")
    @GetMapping("list")
    public R listAll(){
        List<Teacher> teacherList = teacherService.list(null);
        return R.ok().data("teacherList", teacherList).message("获取所有讲师列表成功!");
    }

    @ApiOperation(value = "根据ID获取讲师信息")
    @GetMapping("get/{id}")
    public R get(@ApiParam(value = "讲师ID", required = true) @PathVariable String id) {
        Map<String, Object> map = teacherService.selectTeacherInfoById(id);
        return R.ok().data(map);
    }
}
